package com.scitc.service;

import com.scitc.mapper.UserMapper;
import com.scitc.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: zk
 * @date: 2021/5/6 0:41
 * @description:
 */
@Service
public class UserService {

    @Autowired
    UserMapper userMapper;

    // 通过 username 获得 User 对象
    public User getUserByUsername(String username) {
        return userMapper.getUserByUsername(username);
    }

    // 通过 id 获得 User 对象
    public User getUserById(String id) {
        return userMapper.getUserById(id);
    }

    // 通过 id 设置 remember
    public int setUserRememberById(String id, boolean isRemember) {
        return userMapper.setUserRememberById(id, isRemember);
    }

    // 添加 user
    public int addUser(User user) {
        return userMapper.addUser(user);
    }

    // 通过 id 修改 name
    public int changeNameById(String id, String name) {
        return userMapper.changeNameById(id, name);
    }

    // 通过 id 修改 password
    public int changePasswordById(String id, String password) {
        return userMapper.changePasswordById(id, password);
    }
}
